{include file="header/index" /}
<div class="container Authority hides" style="display: block;">
    <ul class="clearfix" style="margin:0px" id="MenuShowList">
        <li class="fl {if condition="$action eq 'index'"}current{/if}"><a href="{:url('systemset/index')}">系统设置</a></li>
        <li class="fl {if condition="$action eq 'weixin'"}current{/if}"><a href="{:url('systemset/weixin')}">公众号管理</a></li>
        <li class="fl {if condition="$action eq 'channel'"}current{/if}"><a href="{:url('systemset/channel')}">短信/smtp配置</a></li>
    </ul>
</div>
<div class="container bgwhite">
    <div class="system-center">
        <h2>smtp基本配置信息  (若不设置则无法使用密码找回功能</h2>
        <p class="system-center-box">
            <label class="system-center-name">邮箱地址</label>
            <input id="mail" class="system-center-input" type="text" value="{$smtp.MAIL_ADDRESS}" name="MAIL_ADDRESS" placeholder="">
            <span class="col-red ml20">*必填 </span>
        </p>
        <div class="system-center-box">
            <label class="system-center-name">smtp服务器地址</label>
            <input id="smtpAddress" class="system-center-input" type="text" value="{$smtp.MAIL_SMTP}" name="MAIL_SMTP" placeholder="">
            <span class="col-red ml20">*必填 </span>
            <label class="ml15 ">
                <input class="fl mr5" type="checkbox" id="secure" value="" name="MAIL_SECURE" <?php if($smtp['MAIL_SECURE']==true){echo "checked";}?>/>
                SSL
            </label>
        </div>
        <p class="system-center-box">
            <label class="system-center-name">smtp服务器端口号</label>
            <input id="ports" class="system-center-input" type="text" value="{$smtp.MAIL_PORT}" name="" placeholder="">
            <span class="col-red ml20">*必填 </span>
        </p>
        <p class="system-center-box">
            <label class="system-center-name">登录名</label>
            <input id="loginName" class="system-center-web" type="text" value="{$smtp.MAIL_LOGINNAME}" name="MAIL_LOGINNAME" placeholder="">
            <span class="col-red ml20">*必填 </span>
        </p>
        <p class="system-center-box">
            <label class="system-center-name">密码</label>
            <input id="password" class="system-center-web" type="text" value="{$smtp.MAIL_PASSWORD}" name="MAIL_PASSWORD" placeholder="">
            <span class="col-red ml20">*必填 </span>
        </p>
        <p class="system-center-box">
            <label class="system-center-name">测试邮箱</label>
            <input id="test_email" class="system-center-web mr20" type="text" value="" name="" placeholder="">
            <button class="systemCenterBtn" onclick="send_email()">测试</button>
        </p>
        <p class="system-bottom-btn">
        <button type="button" class="system-Determine" onclick="sub_smtp()">保存</button>
        <button type="button" class="system-Reset">重置</button>
    </p>
    </div>

    <div class="system-center">
        <h2>短信配置信息</h2>
        <p class="system-center-box">
            <label class="system-center-name">短信接口用户名</label>
            <input id="uid" class="system-center-web" type="text" value="{$sms.uid}" name="" placeholder="">
        </p>
        <p class="system-center-box">
            <label class="system-center-name">短信接口密码</label>
            <input id="passwd" class="system-center-web" type="text" value="{$sms.passwd}" name="" placeholder="">
        </p>
        <p class="system-center-box">
            <label class="system-center-name">客户短信签名</label>
            <input id="sign_name" class="system-center-web" type="text" value="{$sms.sign_name}" name="" placeholder="">
        </p>
        <p class="system-center-box">
            <label class="system-center-name">内部通知短信签名</label>
            <input id="sign_sysname" class="system-center-web" type="text" value="{$sms.sign_sysname}" name="" placeholder="">
        </p>

        <p class="system-center-box">
            <label class="system-center-name">测试手机</label>
            <input id="test_tel" class="system-center-web mr20" type="text" value="" name="" placeholder="">
            <button class="systemCenterBtn" onclick="send_sms()">发送短信通知</button>
        </p>

    <p class="system-bottom-btn">
        <button type="button" class="system-Determine" onclick="sub_sms()">保存</button>
        <button type="button" class="system-Reset">重置</button>
    </p>
    </div>
</div>

<script>
    //邮箱配置修改
    function sub_smtp(){
        var mail=$("#mail").val();
        var smtpAddress=$("#smtpAddress").val();
        var port=$("#ports").val();
        var loginName=$("#loginName").val();
        var passworda=$("#password").val();
        var secure=$("#secure").is(':checked')
        if(mail==""){
            layer.msg('邮箱地址必填');
            return false;
        }else if(smtpAddress==""){
            layer.msg('smtp服务器地址必填');
            return false;
        }else if(port==""){
            layer.msg('smtp服务器端口号必填');
            return false;
        }else if(loginName==""){
            layer.msg('登录名必填');
            return false;
        }else if(passworda==""){
            layer.msg('密码必填');
            return false;
        }
        $.getJSON("{:url('Systemset/edit')}", {'name':'smtp','MAIL_ADDRESS':mail,'MAIL_SMTP':smtpAddress,'MAIL_PORT':port,'MAIL_LOGINNAME':loginName,'MAIL_PASSWORD':passworda,'MAIL_SECURE':secure}, function(res){
                layer.msg(res.msg);return false;


        });
    }
    //短信配置修改
     function sub_sms(){
        var uid=$("#uid").val();
        var passwd=$("#passwd").val();
        var sign_name=$("#sign_name").val();
        var sign_sysname=$("#sign_sysname").val();
        var passworda=$("#password").val();
        var secure=$("#secure").val();
        if(uid==""){
            layer.msg('请输入UID');
            return false;
        }else if(passwd==""){
            layer.msg('请输入密码');
            return false;
        }else if(sign_name==""){
            layer.msg('请输入客户签名');
            return false;
        }else if(sign_sysname==""){
            layer.msg('请输入内部签名');
            return false;
        }
        $.getJSON("{:url('Systemset/edit')}", {'name':'sms','uid':uid,'passwd':passwd,'sign_name':sign_name,'sign_sysname':sign_sysname}, function(res){
            layer.msg(res.msg);return false;
        });
    }
    //发送邮件
    function send_email(){
        email = $("#test_email").val();
        if(email.length==0){
            layer.msg("请输入测试邮箱地址");return false;
        }
        $.getJSON("{:url('Systemset/sendEmail')}", {'email':email}, function(res){
            console.log(res)
            layer.msg(res.msg);return false;
        });
    }
     //发送短信
    function send_sms(){
        tel = $("#test_tel").val();
        if(tel.length!=11){
            layer.msg("请输入正确的测试手机号");return false;
        }
        $.getJSON("{:url('Systemset/sendsms')}", {'tel':tel}, function(res){
            layer.msg(res.msg);return false;
        });
    }
</script>
</body>
</html>
